#!/bin/python3
import os

getLogsCommand = "ls -1 ./in-logs/"
outLogsCommand = os.popen(getLogsCommand).read().split("\n")

def getLogs():
    global outLogsCommand
    files = []
    for i in outLogsCommand:
        try:
            if i.split(".")[-1] == "log":
                files.append(i)
        except Exception:
            pass
    return files

def readChat():
    chatLines = []
    logFile = open(f"in-logs/{getLogs()[0]}", "r")
    logLines = logFile.read().split("\n")
    x = 0
    while True:
        try:
            logSplited = logLines[x].split()
        except Exception:
            break
        try:
            if logSplited[1] == "[Async" and logSplited[2] == "Chat":
                chatLines.append(x+1)
        except IndexError:
            pass
        x += 1
    return chatLines

print(readChat())
